<?php

$router->get('/hello',function (){
    return '你在访问hello';
});//->middleware(\App\middleware\WebMiddleWare::class);

$router->get('/config',function (){
    echo  App::getContainer()->get('config')->get('db.connections.mysql_one.driver').'<hr/>';
    App::getContainer()->get('config')->set('db.connections.mysql_one.driver','mysql set');
    echo  App::getContainer()->get('config')->get('db.connections.mysql_one.driver');
});
$router->get('/db',function (){
    $id=1;
//    var_dump(
//    //App::getContainer()->get('db')->select('select * from users')
//    App::getContainer()->get('db')->table('users')->where('id',2)->get()
//    );
    $users = \App\User::Where('id',1)->orWhere('id',2)->get();
    foreach ($users as $user){
        echo $user->sayPhp();
    }
});

$router->get('/controller','UserController@index');
$router->get('/view/{id}','UserController@view');
$router->get('/view/blade',function (){
    $str = '這是blade模板';
    return view('blade.index',compact('str'));
});
$router->get('/view/thinkphp',function (){
    $str = '這是thinkphp模板';
    return view('thinkphp.index',compact('str'));
});
$router->get('/log',function (){
    App::getContainer()->get('log')->debug('{language} is the best language in the world',['language'=>'php']);
    App::getContainer()->get('log')->info('hello world');
});

$router->get('/exception',function (){
    throw new \App\exceptions\ErrorMessageException('test exception ');
});
$router->get('/error',function (){
    hello;
});

